package com.AC.ACJingDong;

import java.util.Scanner;

/**
 * 数字三角
 */
public class test2 {



    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = 2 * n + 1;
        matrix = new int[n][m];
        dp = new int[n][m];



        for(int i = 0; i<n; i++){
            for(int j = n - i; j < n +  i + 1 ; j++){
                matrix[i][j] = sc.nextInt();
            }
        }

        System.out.println(dfs(0, n));


    }

    static int[][] dp;

    static int[][] matrix;

    static int res, n, m;

    public static int dfs(int i, int j){
        if(i < 0 || i >= n || j < 0 || j >= m )
            return 0;

        if(dp[i][j] != 0)
            return dp[i][j];

        dp[i][j] = Math.max(Math.max(dfs(i+1,  j), dfs(i+1,j-1)), dfs(i+1,j+1)) + matrix[i][j];

        return dp[i][j];
    }
}
